package com.ruoyi.ly.controller;

import com.ruoyi.ly.service.FileUploadService;
import com.ruoyi.ly.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


@CrossOrigin
@RestController
@RequestMapping("/ly")
@Slf4j
@Api(tags = "文件上传接口")
public class FileUploadController {
    @Autowired
    private FileUploadService fileUploadService;

    @ApiOperation("文件上传接口")
    @PostMapping("/fileUpload")
    public Result<String> fileUpload(MultipartFile file)  {
        //获取上传的文件
        //调用service的方法上传  返回minio路径
        String url = fileUploadService.upload(file);

        return Result.success(url);
    }
}
